#include <iostream>

// main.cpp
#include "Database.h"
#include "Database1.h"
#include <memory>
#include <iostream>

#define NUM_ROWS 100

int main(int argc, char* argv[]) {
    int choice;
    std::cout << "Choose execution method (1: Two-Phase Locking, 2: Pipeline): ";
    std::cin >> choice;

    std::unique_ptr<Transaction> t1 = std::make_unique<Transaction>();
    t1->addOperation(Operation(0, 3, 0));
    t1->addOperation(Operation(1, 4, 5));
    std::unique_ptr<Transaction> t2 = std::make_unique<Transaction>();
    t2->addOperation(Operation(1, 3, 99));
    t2->addOperation(Operation(0, 4, 0));

    std::vector<Transaction> transactions;
    transactions.push_back(*t1);
    transactions.push_back(*t2);

    if (choice == 1) {
        // database
        std::unique_ptr<Database> db = std::make_unique<Database>(NUM_ROWS);
        db->run(transactions);
    } else if (choice == 2) {
        // database
        std::unique_ptr<Database1> db = std::make_unique<Database1>(NUM_ROWS);
        db->run(transactions);
    } else {
        std::cerr << "Invalid choice." << std::endl;
        return 1;
    }
    return 0;
}
